import request from '@/utils/request'

/**
 * 分页查询维修记录
 */
export function getRepairPage(params) {
  return request({
    url: '/repair/page',
    method: 'get',
    params
  })
}

/**
 * 根据车辆ID查询维修记录
 */
export function getRepairListByVehicleId(vehicleId) {
  return request({
    url: `/repair/vehicle/${vehicleId}`,
    method: 'get'
  })
}

/**
 * 根据客户ID查询维修记录
 */
export function getRepairListByCustomerId(customerId) {
  return request({
    url: `/repair/customer/${customerId}`,
    method: 'get'
  })
}

/**
 * 根据ID查询维修记录
 */
export function getRepairById(id) {
  return request({
    url: `/repair/${id}`,
    method: 'get'
  })
}

/**
 * 新增维修记录
 */
export function addRepair(data) {
  return request({
    url: '/repair',
    method: 'post',
    data
  })
}

/**
 * 更新维修记录
 */
export function updateRepair(data) {
  return request({
    url: '/repair',
    method: 'put',
    data
  })
}

/**
 * 更新维修状态
 */
export function updateRepairStatus(id, status) {
  return request({
    url: `/repair/${id}/status`,
    method: 'put',
    params: { status }
  })
}

/**
 * 删除维修记录
 */
export function deleteRepair(id) {
  return request({
    url: `/repair/${id}`,
    method: 'delete'
  })
}

